var video = document.getElementsByClassName("video1")[0];
var playPause = function () {//单击或双击视频时产生的效果
  lock -= 1;
   if(lock == 1){
     if( document.getElementsByClassName('heart-l')[0].classList.contains('heart1')){
      document.getElementsByClassName('heart-l')[0].classList.remove("heart1");
      document.getElementsByClassName('heart-r')[0].classList.remove("heart1");
      document.getElementsByClassName('count')[0].innerHTML -= 1;
      lock = 0;
      return;
     };
    document.getElementsByClassName('heart-l')[0].classList.add('heart1');
    document.getElementsByClassName('heart-r')[0].classList.add('heart1');
    document.getElementsByClassName('count')[0].innerHTML = 1;
    lock = 0;
    return;
   };
  if (video.paused) {
    video.play();
  } else {
    video.pause();
  };
};

var comment = document.getElementsByClassName("comment")[0];
var com = document.getElementsByClassName("com")[0];
var eixt = document.getElementsByClassName('exit')[0];
var heart = document.getElementsByClassName('heart')[0];
var viewp = document.getElementsByClassName('viewport')[0];
var lock = 0
var timer = null;
comment.onclick = function (e) {//点击评论时打开评论框
  com.style.height = "400px";
};


eixt.onclick = function(){//点击×时评论框关闭
  com.style.height = "0px";
};

video.onclick = function(){//单击与双击的逻辑
  clearTimeout(timer);
  timer = null;
  lock+=1;
  timer = setTimeout(playPause,300);
};

heart.onclick = function(e){//点击爱心是产生的效果

    if( document.getElementsByClassName('heart-l')[0].classList.contains('heart1')){
     document.getElementsByClassName('heart-l')[0].classList.remove("heart1");
     document.getElementsByClassName('heart-r')[0].classList.remove("heart1");
     document.getElementsByClassName('count')[0].innerHTML -= 1;
     return;
    };
   document.getElementsByClassName('heart-l')[0].classList.add('heart1');
   document.getElementsByClassName('heart-r')[0].classList.add('heart1');
   document.getElementsByClassName('count')[0].innerHTML = 1;
   
};

var biu = document.getElementsByClassName("biu")[0];
var bala = document.getElementsByClassName("bala")[0];
var coms = document.getElementsByClassName("coms")[0];
biu.onclick = function(){
  if(bala.value){
     coms.innerHTML = coms.innerHTML + `
     <li>
              <img src=${myData.picture} alt="" />
              <div class="ping">
                <p class="name">${myData.name}</p>
                <p class="discuss">
                  ${bala.value}
                  <span>05-15</span>
                </p>
              </div>
              <div class="praise">
                <div class="heart-s"></div>
                <p>0</p>
              </div>
            </li>
     `
  }
  bala.value = "";

}
